# Maintainer: Jan Alexander Steffens (heftig) <heftig@archlinux.org>
# Contributor: György Balló <ballogy@freestart.hu>

pkgbase=gupnp
pkgname=(gupnp gupnp-docs)
pkgver=1.6.3
pkgrel=1
epoch=1
pkgdesc="An object-oriented UPNP framework"
url="https://wiki.gnome.org/Projects/GUPnP"
arch=(x86_64)
license=(LGPL)
depends=(glib2 gssdp libxml2)
makedepends=(gobject-introspection gi-docgen vala meson git)
_commit=adb51197a7e3120027a295b36beda4571e628758  # tags/gupnp-1.6.3^0
source=("git+https://gitlab.gnome.org/GNOME/gupnp.git#commit=$_commit")
sha256sums=('SKIP')

pkgver() {
  cd gupnp
  git describe --tags | sed 's/^gupnp-//;s/[^-]*-g/r&/;s/-/+/g'
}

prepare() {
  cd gupnp
}

build() {
  arch-meson gupnp build -D gtk_doc=true
  meson compile -C build
}

check() {
  meson test -C build --print-errorlogs
}

_pick() {
  local p="$1" f d; shift
  for f; do
    d="$srcdir/$p/${f#$pkgdir/}"
    mkdir -p "$(dirname "$d")"
    mv "$f" "$d"
    rmdir -p --ignore-fail-on-non-empty "$(dirname "$f")"
  done
}


package_gupnp() {
  depends+=(libg{lib,object,io,module}-2.0.so libgssdp-1.6.so libsoup-3.0.so)
  optdepends=('python: gupnp-binding-tool')
  provides=(libgupnp-1.6.so)

  meson install -C build --destdir "$pkgdir"

  cd "$pkgdir"
  _pick docs usr/share/doc
}

package_gupnp-docs() {
  pkgdesc+=" (documentation)"
  depends=()
  mv docs/* "$pkgdir"
}

# vim:set sw=2 sts=-1 et:
